package com.definity.example.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;

import com.definity.example.domain.Person;
import com.definity.example.service.PersonService;
import com.definity.toolkit.web.controller.DWTDataController;

@Resource
public class PersonController extends DWTDataController<Person> {

	@Autowired
	private PersonService personService;
	
	public PersonController(Result result, HttpServletRequest request) {
		super(result, request);
	}

	@Path("/person/")
	public void index() {
		super.index();
	}
	
	@Path("/person/list")
	public List<Person> list() {
		return super.list();
	}
	
	@Path("/person/create")
	public void create() {
		super.create();
	}
	
	@Path("/person/edit/{person.id}")
	public Person edit(Person person) {
		return super.edit(person);
	}
	
	@Path("/person/delete/{person.id}")
	public void delete(Person person) {
		super.delete(person);
	}
	
	@Post("/person/save")
	public void save(Person person) {
		super.save(person);
	}
	
	@Override
	protected Person createDomain() {
		return new Person();
	}

	@Override
	protected PersonService getService() {
		return personService;
	}

}
